﻿<!-- The Star System Page
Note: The DataContext for the whole page is the star. 
      The bindings are a path to the properties of the star
-->
<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Parts="clr-namespace:Majesty_of_Omega.GUI.Pages.Parts"
    xmlns:Majesty_Commands="clr-namespace:Majesty_of_Omega.GUI.Commands"
    xmlns:Controls="clr-namespace:Majesty_of_Omega.GUI.Controls"
    xmlns:PageStarSystemObjects1="clr-namespace:Majesty_of_Omega.GUI.Pages.Game.PageStarSystemObjects;assembly="
    xmlns:Parts1="clr-namespace:Majesty_of_Omega.GUI.Pages.Game.Parts;assembly="
    x:Class="Majesty_of_Omega.GUI.Pages.Game.StarSystemPage"
    Title="PageStarSystem"
    OpacityMask="#FF000000"
    Background="{DynamicResource PlanetStdBackground}"
    >
    <Page.Triggers>
        <EventTrigger RoutedEvent="Page.Loaded">
            <EventTrigger.Actions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation  From="0" To="2880" Duration="0:6:0" AutoReverse="False" RepeatBehavior="Forever" Storyboard.TargetName="MyStarSystem2D" Storyboard.TargetProperty="SystemRotation" />
                    </Storyboard>
                </BeginStoryboard>
                <BeginStoryboard>
                    <Storyboard Duration="0:0:1" SlipBehavior="Slip">
                        <DoubleAnimation From="0.0" To="1.0" Storyboard.TargetName="MyStarSystem2D" Storyboard.TargetProperty="PlanetRelativeAngle"/>
                        <BooleanAnimationUsingKeyFrames Storyboard.TargetName="MyStarSystem2D" Storyboard.TargetProperty="ShowInfoText">
                            <DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="False"/>
                            <DiscreteBooleanKeyFrame KeyTime="0:0:1" Value="True"/>
                        </BooleanAnimationUsingKeyFrames>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.Actions>
        </EventTrigger>
    </Page.Triggers>

    <Page.InputBindings>
        <KeyBinding Command="Majesty_Commands:MainCommands.CancelSubFrameCommand" Key="Escape" />
    </Page.InputBindings>

    <!-- The whole star system canvas  -->
    <Grid x:Name="LayoutMain">
        <!-- This user control provides the orbital rings, the sun and the planet and moons  -->
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="20*"/>
            <ColumnDefinition Width="1*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="20*"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>

        <PageStarSystemObjects1:StarSystem2D x:Name="MyStarSystem2D" Star="{Binding}" />

        <DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="1" Margin="0,4,0,-4" >
            <Parts1:EconomicPanelPart DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Top" Width="300"/>
            <!-- The following stack panel represents the info panel for the main information about the sun, the planets and the moon -->

            <Controls:Panel x:Name="InfoPlanetPanel" Title="{Binding Path=Title}"
                      HorizontalAlignment="Left" VerticalAlignment="Bottom" DockPanel.Dock="Left"
                      >
                <StackPanel Orientation="Vertical" Width="288" AllowDrop="False" Background="{DynamicResource PanelBackgroundBrush}" >
                    <StackPanel.Resources>
                        <DataTemplate x:Key ="InfoPanelData">
                            <Grid Margin="20,5,20,5" >
                                <TextBlock Style="{DynamicResource InfoLabelStyle}" Text="{Binding Path=Label}" />
                                <TextBlock Style="{DynamicResource InfoValueStyle}" Text="{Binding Path=Value}" ToolTip="{Binding Path=ToolTip}" />
                            </Grid>
                        </DataTemplate>
                    </StackPanel.Resources>
                    <ItemsControl  ItemTemplate ="{DynamicResource InfoPanelData}" ItemsSource ="{Binding Path=PanelInfoItems}" />
                </StackPanel>
            </Controls:Panel>
        </DockPanel>
    </Grid>
</Page>
